Numerical failure statuses ========================== A numerical attempt can fail without producing an accepted result. The functions below report such failures with named return codes. An empty result or an unfitted object must be checked before downstream computation. Invalid input shapes, malformed options and programming exceptions remain errors; these statuses do not replace input validation. .. list-table:: Numerical outcomes :header-rows: 1 :widths: 30 35 35 * - Entry point - Failed numeric attempt - Result * - ``bee_root`` - No usable initial residual candidate - Empty ``x`` and ``f``; ``exitflag=OPTIM_NOT_A_ROOT`` * - ``utils.entropic_tilting.core`` and ``tilt_scenario`` - Nonfinite/complex computed moments or numerical weights; unmet target - Empty weights; ``TILT_MOMENT_FAILURE`` or ``OPTIM_NOT_A_ROOT`` * - ``rise.scenario.tilt`` - Unmet moments or inadequate effective sample fraction - Empty result; ``OPTIM_NOT_A_ROOT`` or ``TILT_EFFECTIVE_SAMPLE_SMALL`` * - ``estimate`` on an HDMR object - Polynomial orthogonality check fails - Empty basis/expansion coefficients; ``SURROGATE_BASIS_FAILED`` * - Local-projection ``estimate`` - No usable observations or an unidentified horizon design - Empty result; ``NO_DATA`` or ``LP_NOT_IDENTIFIED`` * - PCE ``fit`` - Design has enough rows but lacks full column rank - Unfitted object, cleared coefficients/design; ``SURROGATE_NOT_IDENTIFIED`` * - ``rise_dram`` - Initial numeric log target is NaN, infinite or complex - Empty chain/covariance; optional sixth output ``SAMPLER_INVALID_START`` * - ``rwmh``, ``imh``, ``slice``, ``apt`` - Same unusable initial numeric log target - Chain result has empty ``pop``, ``best``, ``SIG`` and ``retcode=SAMPLER_INVALID_START`` For APIs with an optional return-code output, zero denotes acceptance. The optimizer ``bee_root`` retains its existing successful exit-flag convention. Use ``utils.error.code('NAME')`` rather than duplicating integer values. Tilting and surrogate fitting ----------------------------- For example:: [weights,info,retcode]=utils.entropic_tilting.core(paths,moments,target); if retcode % No accepted weights; inspect info.residual and info.retcode. return end An unmet target never yields accepted weights, even when only one output is requested. ``tilt_scenario`` also returns an empty forecast structure on failure. The public scenario interface uses the existing moment tolerance and ``MinESS``; the weighting objective, normalization and solver are unchanged. Computed nonfinite or complex moments have their own status. PCE fitting also accepts an optional second output:: [p,retcode]=fit(p,X,y); if retcode % p.is_fitted is false; p.diagnostics.retcode gives the same code. return end prediction=predict(p,Xnew); A failed numeric fit clears a previous successful fit, so stale coefficients cannot be used for prediction. Too few supplied rows, incompatible shapes and nonfinite supplied design values remain input errors. HDMR similarly clears the polynomial and expansion coefficients when its existing numerical orthogonality check fails. The basis algorithms and tolerances are unchanged. The sensitivity report propagates this outcome in ``res.hdmr_retcode``. On failure its ``res.hdmr`` is empty and the HDMR table column stays NaN; independently requested Sobol/MCF results remain available. The status is zero for a successful requested HDMR fit and empty when HDMR was not requested. Sampler initialization and callback errors ------------------------------------------ An initial numeric log-target return of NaN, positive/negative infinity or a complex number cannot initialize a chain. No draws are accepted, and the failure records the actual evaluation count with undefined statistics empty. For the sampler classes, inspect ``results{chain}.retcode`` when that field is present before using ``pop`` or ``best``. Ordinary successful chain structures retain their established fields. If the target callback **throws** during initialization, the original exception is rethrown with its identifier and stack. There is no classifier based on exception wording. A wrong callback output type/shape remains an error. Proposal-time exception handling and rejection probabilities retain their existing behavior. ``rise_dram`` has an optional sixth numeric return code; its first five outputs retain their order. ``usrsmplr`` reads the sixth status from this built-in only. Every other user or built-in callback retains its original five-output call, irrespective of additional outputs it declares. Thus a sixth diagnostic object, numeric count or checkpoint is never interpreted as failure. DSMH's documented ``extras`` remains available through its direct sixth output exactly as before. On startup callback exceptions, the original-exception rule also applies through the adapter.